/*
 * @Author: your name
 * @Date: 2021-09-03 10:08:36
 * @LastEditTime: 2021-09-03 10:24:37
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \briup\5-javascript\day10\3-原型模式.js
 */

//创建一个空的函数方法
function Person() {};
//通过空函数的原型创建对象
Person.prototype.name = "zs";
Person.prototype.age = 12;
Person.prototype.gender = "男";
Person.prototype.like = ["吃饭", "睡觉", "打豆豆"];
Person.prototype.sayName = function() {
    console.log(this.name);
}
var person1 = new Person();
var person2 = new Person();
person1.sayName(); //zs
person2.sayName(); //zs
//通过处理，可以属性结果不同
var person1 = new Person();
person1.name = "lisi";
person1.like.push("打篮球");
var person2 = new Person();
person2.name = "ww";
person1.sayName(); //lisi
person2.sayName(); //ww
console.log(person1.like); //[ '吃饭', '睡觉', '打豆豆', '打篮球' ]
console.log(person2.like); //[ '吃饭', '睡觉', '打豆豆', '打篮球' ]